import java.util.*;
public class Text {
    //491
    List<List<Integer>> ret = new ArrayList<>();
    List<Integer> tmp = new LinkedList<>();

    public void func(int[] nums,int startIndex) {
        if(tmp.size() > 1) {
            ret.add(new ArrayList<>(tmp));
        }
        HashSet<Integer> hashset = new HashSet<>();
        for(int i = startIndex; i < nums.length; i++) {
            if(!tmp.isEmpty() && tmp.get(tmp.size()-1) > nums[i] ||
                    hashset.contains(nums[i])){
                continue;
            }
            hashset.add(nums[i]);
            tmp.add(nums[i]);
            func(nums,i+1);
            tmp.remove(tmp.size()-1);
        }
    }
    public List<List<Integer>> findSubsequences(int[] nums) {
        func(nums,0);
        return ret;
    }
}
